package RedisDay2;

import redis.clients.jedis.Jedis;

import java.util.Set;

public class Redis_SET {
    public static void main(String[] args) {
        Jedis master = new Jedis("192.168.111.166", 7000);
        master.select(2);
        //值类型为set
//        master.sadd("name","小龙","小虎","小凤");
//        master.sadd("name2","老周","老李","小龙");
        //查看
//        Set<String> name = master.smembers("name");
//        for (String s : name) {
//            System.out.println(s);
//        }
        //求交差并
        Set<String> sinter = master.sinter("name", "name2");
        for (String s : sinter) {
            System.out.println(s);
        }
        System.out.println("+++++++++++++++");
        Set<String> sdiff = master.sdiff("name", "name2");
        for (String s : sdiff) {
            System.out.println(s);
        }
        System.out.println("+++++++++++++++");
        Set<String> sunion = master.sunion("name", "name2");
        for (String s : sunion) {
            System.out.println(s);
        }
    }
}
